//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.liy.framework.common.vo;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.ibatis.session.RowBounds;

@JsonIgnoreProperties({"offset", "limit", "maxSize"})
public class PageVO<T> extends RowBounds implements Serializable {
    private static final long serialVersionUID = 1L;
    protected String status = "200";
    protected String message = "";
    private int maxSize = 1000;
    protected int pageNo = 1;
    protected int pageSize = 15;
    protected int offset;
    protected int limit;
    protected List<T> results = new ArrayList();
    protected int totalCount;
    protected int totalPages;

    private void calcOffset() {
        this.offset = (this.pageNo - 1) * this.pageSize + 1;
    }

    private void calcLimit() {
        this.limit = this.pageSize;
    }

    public PageVO() {
        this.calcOffset();
        this.calcLimit();
    }

    public PageVO(int pageNo) {
        this.pageNo = pageNo;
        this.calcOffset();
        this.calcLimit();
    }

    public PageVO(Integer pageNo, Integer pageSize) {
        if (pageNo != null) {
            this.pageNo = pageNo;
        }

        if (pageSize != null) {
            this.pageSize = pageSize;
        }

        this.pageSize = this.pageSize <= this.maxSize ? this.pageSize : this.maxSize;
        this.calcOffset();
        this.calcLimit();
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
        this.calcOffset();
        this.calcLimit();
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize > this.maxSize ? this.maxSize : pageSize;
        this.calcOffset();
        this.calcLimit();
    }

    public int getPageNo() {
        return this.pageNo;
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public int getOffset() {
        return this.offset;
    }

    public int getLimit() {
        return this.limit;
    }

    public List<T> getResults() {
        return this.results;
    }

    public void setResults(List<T> results) {
        this.results = results;
    }

    public int getTotalCount() {
        return this.totalCount;
    }

    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
        this.totalPages = this.getTotalPages();
    }

    public int getTotalPages() {
        if (this.totalCount < 0) {
            return -1;
        } else {
            int pages = this.totalCount / this.pageSize;
            int var10000;
            if (this.totalCount % this.pageSize > 0) {
                ++pages;
                var10000 = pages;
            } else {
                var10000 = pages;
            }

            return var10000;
        }
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }

    public String getStatus() {
        return this.status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
